package com.jy.controller;


import com.jy.common.enums.ResponseWrapper;
import com.jy.common.model.home.AddOrEditSwiperPamras;
import com.jy.service.MainPageSwiperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fzg
 * @since 2024-11-12
 */
@RestController
@RequestMapping("/main-page-swiper")
public class MainPageSwiperController {

    private final MainPageSwiperService mainPageSwiperService;

    public MainPageSwiperController(MainPageSwiperService mainPageSwiperService) {
        this.mainPageSwiperService = mainPageSwiperService;
    }

    /**
     * 获取轮播图(手机端)
     */
    @GetMapping("/getSwiperImage")
    public ResponseWrapper getSwiperImage() {
        return mainPageSwiperService.getSwiperImage();
    }

    /**
     * 获取轮播图列表(后台管理)
     */
    @PostMapping("/addOrEditSwiper")
    public ResponseWrapper addOrEditSwiper(@RequestBody @Validated AddOrEditSwiperPamras pamras) {
        return mainPageSwiperService.addOrEditSwiper(pamras);
    }

    /**
     * 获取轮播图列表(后台管理)
     */
    @GetMapping("/getSwiperImageLisT")
    public ResponseWrapper getSwiperImageLisT() {
        return mainPageSwiperService.getSwiperImageLisT();
    }

    /**
     * 根据轮播类型获取编码(后台管理)
     */
    @GetMapping("/getCode")
    public ResponseWrapper getCode(@RequestParam String typeName) {
        return mainPageSwiperService.getCode(typeName);
    }


    /**
     * 根据轮播图aid删除轮播图(后台管理)
     */
    @DeleteMapping("/deleteSwiperByAid")
    public ResponseWrapper deleteSwiperByAid(@RequestParam Integer swiperAid) {
        return mainPageSwiperService.deleteSwiperByAid(swiperAid);
    }

}
